/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;


init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('bailian', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }
  
  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}

model CancelFineTuneJobRequest {
  agentKey?: string(name='AgentKey', example='ac627989eb4f8a98ed05fd098beee5_p_efm'),
  jobId?: string(name='JobId', example='ft-202307181110-146c93bf'),
}

model CancelFineTuneJobResponseBody = {
  jobId?: string(name='JobId', example='ft-202307181110-146c93bf'),
  requestId?: string(name='RequestId', example='778C0B3B-03C1-5FC1-A947-36EDD13606AB'),
}

model CancelFineTuneJobResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CancelFineTuneJobResponseBody(name='body'),
}

async function cancelFineTuneJobWithOptions(request: CancelFineTuneJobRequest, runtime: Util.RuntimeOptions): CancelFineTuneJobResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.agentKey)) {
    query['AgentKey'] = request.agentKey;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.jobId)) {
    body['JobId'] = request.jobId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CancelFineTuneJob',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function cancelFineTuneJob(request: CancelFineTuneJobRequest): CancelFineTuneJobResponse {
  var runtime = new Util.RuntimeOptions{};
  return cancelFineTuneJobWithOptions(request, runtime);
}

model CreateDocumentTagRequest {
  agentKey?: string(name='AgentKey'),
  name?: string(name='Name'),
}

model CreateDocumentTagResponseBody = {
  requestId?: string(name='RequestId'),
  tagId?: string(name='TagId'),
}

model CreateDocumentTagResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateDocumentTagResponseBody(name='body'),
}

async function createDocumentTagWithOptions(request: CreateDocumentTagRequest, runtime: Util.RuntimeOptions): CreateDocumentTagResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.agentKey)) {
    query['AgentKey'] = request.agentKey;
  }
  if (!Util.isUnset(request.name)) {
    query['Name'] = request.name;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateDocumentTag',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createDocumentTag(request: CreateDocumentTagRequest): CreateDocumentTagResponse {
  var runtime = new Util.RuntimeOptions{};
  return createDocumentTagWithOptions(request, runtime);
}

model CreateFineTuneJobRequest {
  agentKey?: string(name='AgentKey', example='ac627989eb4f8a98ed05fd098beee5_p_efm'),
  baseModel?: string(name='BaseModel', example='bailian-qwen-basic-v1'),
  hyperParameters?: {
    batchSize?: int32(name='BatchSize', example='32'),
    epochs?: int32(name='Epochs', example='10'),
    learningRate?: string(name='LearningRate', example='2e-5'),
    promptLossWeight?: double(name='PromptLossWeight', example='1.0'),
  }(name='HyperParameters'),
  modelName?: string(name='ModelName'),
  trainingFiles?: [ string ](name='TrainingFiles'),
  trainingType?: string(name='TrainingType'),
  validationFiles?: [ string ](name='ValidationFiles'),
}

model CreateFineTuneJobShrinkRequest {
  agentKey?: string(name='AgentKey', example='ac627989eb4f8a98ed05fd098beee5_p_efm'),
  baseModel?: string(name='BaseModel', example='bailian-qwen-basic-v1'),
  hyperParametersShrink?: string(name='HyperParameters'),
  modelName?: string(name='ModelName'),
  trainingFilesShrink?: string(name='TrainingFiles'),
  trainingType?: string(name='TrainingType'),
  validationFilesShrink?: string(name='ValidationFiles'),
}

model CreateFineTuneJobResponseBody = {
  jobId?: string(name='JobId', example='ft-202307181110-146c93bf'),
  requestId?: string(name='RequestId', example='7BA8ADD9-53D6-53F0-918F-A1E776AD230E'),
  status?: string(name='Status', example='- SUCCESSED
- PENDING
- RUNNING
- FAILED
- CANCELED'),
}

model CreateFineTuneJobResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateFineTuneJobResponseBody(name='body'),
}

async function createFineTuneJobWithOptions(tmpReq: CreateFineTuneJobRequest, runtime: Util.RuntimeOptions): CreateFineTuneJobResponse {
  Util.validateModel(tmpReq);
  var request = new CreateFineTuneJobShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.hyperParameters)) {
    request.hyperParametersShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.hyperParameters, 'HyperParameters', 'json');
  }
  if (!Util.isUnset(tmpReq.trainingFiles)) {
    request.trainingFilesShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.trainingFiles, 'TrainingFiles', 'json');
  }
  if (!Util.isUnset(tmpReq.validationFiles)) {
    request.validationFilesShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.validationFiles, 'ValidationFiles', 'json');
  }
  var query = {};
  if (!Util.isUnset(request.agentKey)) {
    query['AgentKey'] = request.agentKey;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.baseModel)) {
    body['BaseModel'] = request.baseModel;
  }
  if (!Util.isUnset(request.hyperParametersShrink)) {
    body['HyperParameters'] = request.hyperParametersShrink;
  }
  if (!Util.isUnset(request.modelName)) {
    body['ModelName'] = request.modelName;
  }
  if (!Util.isUnset(request.trainingFilesShrink)) {
    body['TrainingFiles'] = request.trainingFilesShrink;
  }
  if (!Util.isUnset(request.trainingType)) {
    body['TrainingType'] = request.trainingType;
  }
  if (!Util.isUnset(request.validationFilesShrink)) {
    body['ValidationFiles'] = request.validationFilesShrink;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateFineTuneJob',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createFineTuneJob(request: CreateFineTuneJobRequest): CreateFineTuneJobResponse {
  var runtime = new Util.RuntimeOptions{};
  return createFineTuneJobWithOptions(request, runtime);
}

model CreateServiceRequest {
  agentKey?: string(name='AgentKey', example='ac627989eb4f8a98ed05fd098beee5_p_efm'),
  model?: string(name='Model', example='bailian-qwen-basic-v1-ft-202307111653-d2d7dbff'),
}

model CreateServiceResponseBody = {
  modelServiceId?: string(name='ModelServiceId', example='bailian-qwen-basic-v1-ft-202307111653-d2d7dbff'),
  requestId?: string(name='RequestId', example='35A267BF-FBFA-54DB-8394-AA3B0742D833'),
}

model CreateServiceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateServiceResponseBody(name='body'),
}

async function createServiceWithOptions(request: CreateServiceRequest, runtime: Util.RuntimeOptions): CreateServiceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.agentKey)) {
    query['AgentKey'] = request.agentKey;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.model)) {
    body['Model'] = request.model;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'CreateService',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createService(request: CreateServiceRequest): CreateServiceResponse {
  var runtime = new Util.RuntimeOptions{};
  return createServiceWithOptions(request, runtime);
}

model CreateTextEmbeddingsRequest {
  agentKey?: string(name='AgentKey'),
  input?: [ string ](name='Input'),
  textType?: string(name='TextType'),
}

model CreateTextEmbeddingsShrinkRequest {
  agentKey?: string(name='AgentKey'),
  inputShrink?: string(name='Input'),
  textType?: string(name='TextType'),
}

model CreateTextEmbeddingsResponseBody = {
  code?: string(name='Code'),
  data?: {
    embeddings?: [ 
      {
        embedding?: [ double ](name='Embedding'),
        textIndex?: int32(name='TextIndex'),
      }
    ](name='Embeddings'),
  }(name='Data'),
  httpStatusCode?: string(name='HttpStatusCode'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model CreateTextEmbeddingsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateTextEmbeddingsResponseBody(name='body'),
}

async function createTextEmbeddingsWithOptions(tmpReq: CreateTextEmbeddingsRequest, runtime: Util.RuntimeOptions): CreateTextEmbeddingsResponse {
  Util.validateModel(tmpReq);
  var request = new CreateTextEmbeddingsShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.input)) {
    request.inputShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.input, 'Input', 'json');
  }
  var query = {};
  if (!Util.isUnset(request.agentKey)) {
    query['AgentKey'] = request.agentKey;
  }
  if (!Util.isUnset(request.inputShrink)) {
    query['Input'] = request.inputShrink;
  }
  if (!Util.isUnset(request.textType)) {
    query['TextType'] = request.textType;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateTextEmbeddings',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createTextEmbeddings(request: CreateTextEmbeddingsRequest): CreateTextEmbeddingsResponse {
  var runtime = new Util.RuntimeOptions{};
  return createTextEmbeddingsWithOptions(request, runtime);
}

model CreateTokenRequest {
  agentKey?: string(name='AgentKey', example='ac627989eb4f8a98ed05fd098beee5_p_efm'),
}

model CreateTokenResponseBody = {
  code?: string(name='Code', example='Forbidden'),
  data?: {
    expiredTime?: long(name='ExpiredTime', example='1664177985651'),
    token?: string(name='Token', example='89158587dfb7d85a335f98de4966d840'),
  }(name='Data'),
  httpStatusCode?: string(name='HttpStatusCode', example='200'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', description='Id of the request', example='778C0B3B-03C1-5FC1-A947-36EDD13606AB'),
  success?: boolean(name='Success', example='True'),
}

model CreateTokenResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: CreateTokenResponseBody(name='body'),
}

async function createTokenWithOptions(request: CreateTokenRequest, runtime: Util.RuntimeOptions): CreateTokenResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.agentKey)) {
    query['AgentKey'] = request.agentKey;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'CreateToken',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function createToken(request: CreateTokenRequest): CreateTokenResponse {
  var runtime = new Util.RuntimeOptions{};
  return createTokenWithOptions(request, runtime);
}

model DeleteDocRequest {
  agentKey?: string(name='AgentKey'),
  docId?: string(name='DocId'),
}

model DeleteDocResponseBody = {
  docId?: string(name='DocId'),
  requestId?: string(name='RequestId'),
}

model DeleteDocResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DeleteDocResponseBody(name='body'),
}

async function deleteDocWithOptions(request: DeleteDocRequest, runtime: Util.RuntimeOptions): DeleteDocResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.agentKey)) {
    query['AgentKey'] = request.agentKey;
  }
  if (!Util.isUnset(request.docId)) {
    query['DocId'] = request.docId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DeleteDoc',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function deleteDoc(request: DeleteDocRequest): DeleteDocResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteDocWithOptions(request, runtime);
}

model DeleteDocumentTagRequest {
  agentKey?: string(name='AgentKey'),
  tagId?: string(name='TagId'),
}

model DeleteDocumentTagResponseBody = {
  requestId?: string(name='RequestId'),
  tagId?: string(name='TagId'),
}

model DeleteDocumentTagResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DeleteDocumentTagResponseBody(name='body'),
}

async function deleteDocumentTagWithOptions(request: DeleteDocumentTagRequest, runtime: Util.RuntimeOptions): DeleteDocumentTagResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.agentKey)) {
    query['AgentKey'] = request.agentKey;
  }
  if (!Util.isUnset(request.tagId)) {
    query['TagId'] = request.tagId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DeleteDocumentTag',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function deleteDocumentTag(request: DeleteDocumentTagRequest): DeleteDocumentTagResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteDocumentTagWithOptions(request, runtime);
}

model DeleteFineTuneJobRequest {
  agentKey?: string(name='AgentKey', example='ac627989eb4f8a98ed05fd098beee5_p_efm'),
  jobId?: string(name='JobId', example='ft-202307181110-146c93bf'),
}

model DeleteFineTuneJobResponseBody = {
  jobId?: string(name='JobId', example='ft-202307181110-146c93bf'),
  requestId?: string(name='RequestId', example='2C4E7A9B-C790-5FA7-9C00-F2661DDB5432'),
}

model DeleteFineTuneJobResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DeleteFineTuneJobResponseBody(name='body'),
}

async function deleteFineTuneJobWithOptions(request: DeleteFineTuneJobRequest, runtime: Util.RuntimeOptions): DeleteFineTuneJobResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.agentKey)) {
    query['AgentKey'] = request.agentKey;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.jobId)) {
    body['JobId'] = request.jobId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'DeleteFineTuneJob',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function deleteFineTuneJob(request: DeleteFineTuneJobRequest): DeleteFineTuneJobResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteFineTuneJobWithOptions(request, runtime);
}

model DeleteServiceRequest {
  agentKey?: string(name='AgentKey', example='ac627989eb4f8a98ed05fd098beee5_p_efm'),
  modelServiceId?: string(name='ModelServiceId', example='bailian-qwen-basic-v1-ft-202307111653-d2d7dbff'),
}

model DeleteServiceResponseBody = {
  modelServiceId?: string(name='ModelServiceId', example='bailian-qwen-basic-v1-ft-202307111653-d2d7dbff'),
  requestId?: string(name='RequestId', example='17204B98-7734-4F9A-8464-2446A84821CA'),
}

model DeleteServiceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DeleteServiceResponseBody(name='body'),
}

async function deleteServiceWithOptions(request: DeleteServiceRequest, runtime: Util.RuntimeOptions): DeleteServiceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.agentKey)) {
    query['AgentKey'] = request.agentKey;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.modelServiceId)) {
    body['ModelServiceId'] = request.modelServiceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'DeleteService',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function deleteService(request: DeleteServiceRequest): DeleteServiceResponse {
  var runtime = new Util.RuntimeOptions{};
  return deleteServiceWithOptions(request, runtime);
}

model DescribeDocRequest {
  agentKey?: string(name='AgentKey'),
  docId?: string(name='DocId'),
}

model DescribeDocResponseBody = {
  docId?: string(name='DocId'),
  failReason?: string(name='FailReason'),
  name?: string(name='Name'),
  ownerId?: string(name='OwnerId'),
  requestId?: string(name='RequestId'),
  size?: string(name='Size'),
  status?: string(name='Status'),
  tags?: [ 
    {
      tagId?: string(name='TagId'),
      tagName?: string(name='TagName'),
    }
  ](name='Tags'),
  type?: string(name='Type'),
  uploadTime?: string(name='UploadTime'),
}

model DescribeDocResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DescribeDocResponseBody(name='body'),
}

async function describeDocWithOptions(request: DescribeDocRequest, runtime: Util.RuntimeOptions): DescribeDocResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.agentKey)) {
    query['AgentKey'] = request.agentKey;
  }
  if (!Util.isUnset(request.docId)) {
    query['DocId'] = request.docId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeDoc',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeDoc(request: DescribeDocRequest): DescribeDocResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeDocWithOptions(request, runtime);
}

model DescribeDocumentImportJobRequest {
  agentKey?: string(name='AgentKey'),
  jobId?: string(name='JobId'),
}

model DescribeDocumentImportJobResponseBody = {
  docs?: [ 
    {
      docId?: string(name='DocId'),
      failReason?: string(name='FailReason'),
      name?: string(name='Name'),
      status?: string(name='Status'),
    }
  ](name='Docs'),
  jobId?: string(name='JobId'),
  requestId?: string(name='RequestId'),
  status?: string(name='Status'),
}

model DescribeDocumentImportJobResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DescribeDocumentImportJobResponseBody(name='body'),
}

async function describeDocumentImportJobWithOptions(request: DescribeDocumentImportJobRequest, runtime: Util.RuntimeOptions): DescribeDocumentImportJobResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.agentKey)) {
    query['AgentKey'] = request.agentKey;
  }
  if (!Util.isUnset(request.jobId)) {
    query['JobId'] = request.jobId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'DescribeDocumentImportJob',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeDocumentImportJob(request: DescribeDocumentImportJobRequest): DescribeDocumentImportJobResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeDocumentImportJobWithOptions(request, runtime);
}

model DescribeFineTuneJobRequest {
  agentKey?: string(name='AgentKey', example='ac627989eb4f8a98ed05fd098beee5_p_efm'),
  jobId?: string(name='JobId', example='ft-202307181110-146c93bf'),
}

model DescribeFineTuneJobResponseBody = {
  baseModel?: string(name='BaseModel', example='bailian-qwen-basic-v1'),
  fineTunedModel?: string(name='FineTunedModel', example='bailian-qwen-basic-v1-ft-202307111653-d2d7dbff'),
  hyperParameters?: {
    batchSize?: int32(name='BatchSize', example='32'),
    epochs?: int32(name='Epochs', example='10'),
    learningRate?: string(name='LearningRate', example='2e-5'),
    promptLossWeight?: double(name='PromptLossWeight', example='1.0'),
  }(name='HyperParameters'),
  jobId?: string(name='JobId', example='ft-202307181110-146c93bf'),
  message?: string(name='Message'),
  modelName?: string(name='ModelName'),
  requestId?: string(name='RequestId', example='1C139002-0EC5-584C-A755-4B8B9FA080BE'),
  status?: string(name='Status', example='- FAILED
- RUNNING
- CANCELED
- PENDING
- SUCCESSED'),
  trainingFiles?: [ string ](name='TrainingFiles', example='https://broadscope-train-pre.oss-cn-beijing.aliyuncs.com/copus-train1686040661321.xlsx'),
  trainingType?: string(name='TrainingType'),
  validationFiles?: [ string ](name='ValidationFiles', example='https://broadscope-train-pre.oss-cn-beijing.aliyuncs.com/copus-train1686040661321.xlsx'),
}

model DescribeFineTuneJobResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DescribeFineTuneJobResponseBody(name='body'),
}

async function describeFineTuneJobWithOptions(request: DescribeFineTuneJobRequest, runtime: Util.RuntimeOptions): DescribeFineTuneJobResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.agentKey)) {
    query['AgentKey'] = request.agentKey;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.jobId)) {
    body['JobId'] = request.jobId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'DescribeFineTuneJob',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeFineTuneJob(request: DescribeFineTuneJobRequest): DescribeFineTuneJobResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeFineTuneJobWithOptions(request, runtime);
}

model DescribeServiceRequest {
  agentKey?: string(name='AgentKey', example='ac627989eb4f8a98ed05fd098beee5_p_efm'),
  modelServiceId?: string(name='ModelServiceId', example='bailian-qwen-basic-v1-ft-202307111653-d2d7dbff'),
}

model DescribeServiceResponseBody = {
  appId?: string(name='AppId', example='3e45511d55b54392a40d7b47a16dad28'),
  modelServiceId?: string(name='ModelServiceId', example='bailian-qwen-basic-v1-ft-202307111653-d2d7dbff'),
  requestId?: string(name='RequestId', example='17204B98-7734-4F9A-8464-2446A84821CA'),
  status?: string(name='Status', example='- RUNNING
- ARREARS_DOWN
- ARREARS_RECOVERING
- PENDING
- FAILED
- OFFLINING'),
}

model DescribeServiceResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: DescribeServiceResponseBody(name='body'),
}

async function describeServiceWithOptions(request: DescribeServiceRequest, runtime: Util.RuntimeOptions): DescribeServiceResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.agentKey)) {
    query['AgentKey'] = request.agentKey;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.modelServiceId)) {
    body['ModelServiceId'] = request.modelServiceId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'DescribeService',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function describeService(request: DescribeServiceRequest): DescribeServiceResponse {
  var runtime = new Util.RuntimeOptions{};
  return describeServiceWithOptions(request, runtime);
}

model GetFileStoreUploadPolicyRequest {
  agentKey?: string(name='AgentKey'),
  fileName?: string(name='FileName'),
  fileStoreId?: long(name='FileStoreId'),
  userId?: string(name='UserId'),
}

model GetFileStoreUploadPolicyResponseBody = {
  data?: {
    accessId?: string(name='AccessId'),
    dir?: string(name='Dir'),
    expire?: string(name='Expire'),
    host?: string(name='Host'),
    key?: string(name='Key'),
    policy?: string(name='Policy'),
    securityToken?: string(name='SecurityToken'),
    signature?: string(name='Signature'),
  }(name='Data'),
  errorCode?: string(name='ErrorCode'),
  errorMsg?: string(name='ErrorMsg'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model GetFileStoreUploadPolicyResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetFileStoreUploadPolicyResponseBody(name='body'),
}

async function getFileStoreUploadPolicyWithOptions(request: GetFileStoreUploadPolicyRequest, runtime: Util.RuntimeOptions): GetFileStoreUploadPolicyResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.agentKey)) {
    query['AgentKey'] = request.agentKey;
  }
  if (!Util.isUnset(request.fileName)) {
    query['FileName'] = request.fileName;
  }
  if (!Util.isUnset(request.fileStoreId)) {
    query['FileStoreId'] = request.fileStoreId;
  }
  if (!Util.isUnset(request.userId)) {
    query['UserId'] = request.userId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetFileStoreUploadPolicy',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getFileStoreUploadPolicy(request: GetFileStoreUploadPolicyRequest): GetFileStoreUploadPolicyResponse {
  var runtime = new Util.RuntimeOptions{};
  return getFileStoreUploadPolicyWithOptions(request, runtime);
}

model GetPromptRequest {
  agentKey?: string(name='AgentKey', example='c160c841c8e54295bf2f441432785944_p_efm'),
  promptId?: string(name='PromptId', example='marketCopy'),
  vars?: string(name='Vars'),
}

model GetPromptResponseBody = {
  code?: string(name='Code', example='100004'),
  data?: {
    promptContent?: string(name='PromptContent'),
    promptId?: string(name='PromptId', example='marketCopy'),
  }(name='Data'),
  httpStatusCode?: string(name='HttpStatusCode', example='200'),
  message?: string(name='Message'),
  requestId?: string(name='RequestId', description='Id of the request', example='1C139002-0EC5-584C-A755-4B8B9FA080BE'),
  success?: boolean(name='Success', example='True'),
}

model GetPromptResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetPromptResponseBody(name='body'),
}

async function getPromptWithOptions(request: GetPromptRequest, runtime: Util.RuntimeOptions): GetPromptResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.agentKey)) {
    query['AgentKey'] = request.agentKey;
  }
  if (!Util.isUnset(request.promptId)) {
    query['PromptId'] = request.promptId;
  }
  if (!Util.isUnset(request.vars)) {
    query['Vars'] = request.vars;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetPrompt',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getPrompt(request: GetPromptRequest): GetPromptResponse {
  var runtime = new Util.RuntimeOptions{};
  return getPromptWithOptions(request, runtime);
}

model GetText2ImageJobRequest {
  agentKey?: string(name='AgentKey'),
  taskId?: string(name='TaskId'),
}

model GetText2ImageJobResponseBody = {
  images?: [ 
    {
      code?: string(name='Code'),
      message?: string(name='Message'),
      URL?: string(name='URL'),
    }
  ](name='Images'),
  requestId?: string(name='RequestId'),
  taskId?: string(name='TaskId'),
  taskMetrics?: {
    failed?: int32(name='Failed'),
    succeeded?: int32(name='Succeeded'),
    total?: int32(name='Total'),
  }(name='TaskMetrics'),
  taskStatus?: string(name='TaskStatus'),
  usage?: [ 
    {
      imageCount?: int32(name='ImageCount'),
    }
  ](name='Usage'),
}

model GetText2ImageJobResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: GetText2ImageJobResponseBody(name='body'),
}

async function getText2ImageJobWithOptions(request: GetText2ImageJobRequest, runtime: Util.RuntimeOptions): GetText2ImageJobResponse {
  Util.validateModel(request);
  var query = OpenApiUtil.query(Util.toMap(request));
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'GetText2ImageJob',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'GET',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function getText2ImageJob(request: GetText2ImageJobRequest): GetText2ImageJobResponse {
  var runtime = new Util.RuntimeOptions{};
  return getText2ImageJobWithOptions(request, runtime);
}

model ImportUserDocumentRequest {
  agentKey?: string(name='AgentKey'),
  fileName?: string(name='FileName'),
  fileStoreId?: long(name='FileStoreId'),
  ossPath?: string(name='OssPath'),
  storeId?: long(name='StoreId'),
  userId?: string(name='UserId'),
}

model ImportUserDocumentResponseBody = {
  data?: {
    dataId?: string(name='DataId'),
    dataStatus?: long(name='DataStatus'),
  }(name='Data'),
  errorCode?: string(name='ErrorCode'),
  errorMsg?: string(name='ErrorMsg'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model ImportUserDocumentResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ImportUserDocumentResponseBody(name='body'),
}

async function importUserDocumentWithOptions(request: ImportUserDocumentRequest, runtime: Util.RuntimeOptions): ImportUserDocumentResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.agentKey)) {
    query['AgentKey'] = request.agentKey;
  }
  if (!Util.isUnset(request.fileName)) {
    query['FileName'] = request.fileName;
  }
  if (!Util.isUnset(request.fileStoreId)) {
    query['FileStoreId'] = request.fileStoreId;
  }
  if (!Util.isUnset(request.ossPath)) {
    query['OssPath'] = request.ossPath;
  }
  if (!Util.isUnset(request.storeId)) {
    query['StoreId'] = request.storeId;
  }
  if (!Util.isUnset(request.userId)) {
    query['UserId'] = request.userId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ImportUserDocument',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function importUserDocument(request: ImportUserDocumentRequest): ImportUserDocumentResponse {
  var runtime = new Util.RuntimeOptions{};
  return importUserDocumentWithOptions(request, runtime);
}

model ListDocsRequest {
  agentKey?: string(name='AgentKey'),
  name?: string(name='Name'),
  pageNo?: int32(name='PageNo', example='1'),
  pageSize?: int32(name='PageSize', example='20'),
  storeId?: string(name='StoreId'),
  tagIds?: [ string ](name='TagIds'),
}

model ListDocsShrinkRequest {
  agentKey?: string(name='AgentKey'),
  name?: string(name='Name'),
  pageNo?: int32(name='PageNo', example='1'),
  pageSize?: int32(name='PageSize', example='20'),
  storeId?: string(name='StoreId'),
  tagIdsShrink?: string(name='TagIds'),
}

model ListDocsResponseBody = {
  docs?: [ 
    {
      docId?: string(name='DocId'),
      failReason?: string(name='FailReason'),
      name?: string(name='Name'),
      ownerId?: string(name='OwnerId'),
      size?: string(name='Size'),
      status?: string(name='Status'),
      tags?: [ 
        {
          tagId?: string(name='TagId'),
          tagName?: string(name='TagName'),
        }
      ](name='Tags'),
      type?: string(name='Type'),
      uploadTime?: string(name='UploadTime'),
    }
  ](name='Docs'),
  pageNo?: int32(name='PageNo'),
  pageSize?: int32(name='PageSize'),
  requestId?: string(name='RequestId'),
  total?: int32(name='Total'),
}

model ListDocsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListDocsResponseBody(name='body'),
}

async function listDocsWithOptions(tmpReq: ListDocsRequest, runtime: Util.RuntimeOptions): ListDocsResponse {
  Util.validateModel(tmpReq);
  var request = new ListDocsShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.tagIds)) {
    request.tagIdsShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.tagIds, 'TagIds', 'json');
  }
  var query = {};
  if (!Util.isUnset(request.agentKey)) {
    query['AgentKey'] = request.agentKey;
  }
  if (!Util.isUnset(request.name)) {
    query['Name'] = request.name;
  }
  if (!Util.isUnset(request.pageNo)) {
    query['PageNo'] = request.pageNo;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.storeId)) {
    query['StoreId'] = request.storeId;
  }
  if (!Util.isUnset(request.tagIdsShrink)) {
    query['TagIds'] = request.tagIdsShrink;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListDocs',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listDocs(request: ListDocsRequest): ListDocsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listDocsWithOptions(request, runtime);
}

model ListDocumentTagsRequest {
  agentKey?: string(name='AgentKey'),
  name?: string(name='Name'),
  pageNo?: int32(name='PageNo', example='1'),
  pageSize?: int32(name='PageSize', example='20'),
  tagId?: string(name='TagId'),
}

model ListDocumentTagsResponseBody = {
  pageNo?: int32(name='PageNo'),
  pageSize?: int32(name='PageSize'),
  requestId?: string(name='RequestId'),
  tagList?: [ 
    {
      name?: string(name='Name'),
      tagId?: string(name='TagId'),
    }
  ](name='TagList'),
  total?: int32(name='Total'),
}

model ListDocumentTagsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListDocumentTagsResponseBody(name='body'),
}

async function listDocumentTagsWithOptions(request: ListDocumentTagsRequest, runtime: Util.RuntimeOptions): ListDocumentTagsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.agentKey)) {
    query['AgentKey'] = request.agentKey;
  }
  if (!Util.isUnset(request.name)) {
    query['Name'] = request.name;
  }
  if (!Util.isUnset(request.pageNo)) {
    query['PageNo'] = request.pageNo;
  }
  if (!Util.isUnset(request.pageSize)) {
    query['PageSize'] = request.pageSize;
  }
  if (!Util.isUnset(request.tagId)) {
    query['TagId'] = request.tagId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'ListDocumentTags',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listDocumentTags(request: ListDocumentTagsRequest): ListDocumentTagsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listDocumentTagsWithOptions(request, runtime);
}

model ListFineTuneJobsRequest {
  agentKey?: string(name='AgentKey', example='ac627989eb4f8a98ed05fd098beee5_p_efm'),
  pageNo?: int32(name='PageNo', example='1'),
  pageSize?: int32(name='PageSize', example='10'),
}

model ListFineTuneJobsResponseBody = {
  jobs?: [ 
    {
      baseModel?: string(name='BaseModel', example='bailian-qwen-basic-v1'),
      fineTunedModel?: string(name='FineTunedModel', example='bailian-qwen-basic-v1-ft-202307111653-d2d7dbff'),
      hyperParameters?: {
        batchSize?: int32(name='BatchSize', example='32'),
        epochs?: int32(name='Epochs', example='10'),
        learningRate?: string(name='LearningRate', example='2e-5'),
        promptLossWeight?: double(name='PromptLossWeight', example='1.0'),
      }(name='HyperParameters'),
      jobId?: string(name='JobId', example='ft-202307181110-146c93bf'),
      message?: string(name='Message'),
      modelName?: string(name='ModelName'),
      status?: string(name='Status', example='- FAILED
- RUNNING
- CANCELED
- PENDING
- SUCCESSED'),
      trainingFiles?: [ string ](name='TrainingFiles', example='https://broadscope-train-pre.oss-cn-beijing.aliyuncs.com/copus-train1686040661321.xlsx'),
      trainingType?: string(name='TrainingType'),
      validationFiles?: [ string ](name='ValidationFiles', example='https://broadscope-train-pre.oss-cn-beijing.aliyuncs.com/copus-train1686040661321.xlsx'),
    }
  ](name='Jobs'),
  pageNo?: int32(name='PageNo', example='1'),
  pageSize?: int32(name='PageSize', example='10'),
  requestId?: string(name='RequestId', example='8F97A63B-55F1-527F-9D6E-467B6A7E8CF1'),
  total?: int32(name='Total', example='10'),
}

model ListFineTuneJobsResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListFineTuneJobsResponseBody(name='body'),
}

async function listFineTuneJobsWithOptions(request: ListFineTuneJobsRequest, runtime: Util.RuntimeOptions): ListFineTuneJobsResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.agentKey)) {
    query['AgentKey'] = request.agentKey;
  }
  var body : map[string]any = {};
  if (!Util.isUnset(request.pageNo)) {
    body['PageNo'] = request.pageNo;
  }
  if (!Util.isUnset(request.pageSize)) {
    body['PageSize'] = request.pageSize;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ListFineTuneJobs',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listFineTuneJobs(request: ListFineTuneJobsRequest): ListFineTuneJobsResponse {
  var runtime = new Util.RuntimeOptions{};
  return listFineTuneJobsWithOptions(request, runtime);
}

model ListServicesRequest {
  agentKey?: string(name='AgentKey', example='ac627989eb4f8a98ed05fd098beee5_p_efm'),
  pageNo?: int32(name='PageNo', example='1'),
  pageSize?: int32(name='PageSize', example='10'),
}

model ListServicesResponseBody = {
  modelServices?: [ 
    {
      appId?: string(name='AppId', example='3e45511d55b54392a40d7b47a16dad28'),
      modelServiceId?: string(name='ModelServiceId', example='bailian-qwen-basic-v1-ft-202307111653-d2d7dbff'),
      status?: string(name='Status', example='- OFFLINING
- FAILED
- PENDING
- ARREARS_RECOVERING
- ARREARS_DOWN
- RUNNING'),
    }
  ](name='ModelServices'),
  pageNo?: int32(name='PageNo', example='1'),
  pageSize?: int32(name='PageSize', example='10'),
  requestId?: string(name='RequestId', example='E45491D5-7E0A-42C6-9B21-91D1066B1475'),
  total?: int32(name='Total', example='30'),
}

model ListServicesResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: ListServicesResponseBody(name='body'),
}

async function listServicesWithOptions(request: ListServicesRequest, runtime: Util.RuntimeOptions): ListServicesResponse {
  Util.validateModel(request);
  var body : map[string]any = {};
  if (!Util.isUnset(request.agentKey)) {
    body['AgentKey'] = request.agentKey;
  }
  if (!Util.isUnset(request.pageNo)) {
    body['PageNo'] = request.pageNo;
  }
  if (!Util.isUnset(request.pageSize)) {
    body['PageSize'] = request.pageSize;
  }
  var req = new OpenApi.OpenApiRequest{ 
    body = OpenApiUtil.parseToMap(body),
  };
  var params = new OpenApi.Params{
    action = 'ListServices',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function listServices(request: ListServicesRequest): ListServicesResponse {
  var runtime = new Util.RuntimeOptions{};
  return listServicesWithOptions(request, runtime);
}

model QueryUserDocumentRequest {
  agentKey?: string(name='AgentKey'),
  dataId?: string(name='DataId'),
  userId?: string(name='UserId'),
}

model QueryUserDocumentResponseBody = {
  data?: {
    dataId?: string(name='DataId'),
    dataStatus?: long(name='DataStatus'),
  }(name='Data'),
  errorCode?: string(name='ErrorCode'),
  errorMsg?: string(name='ErrorMsg'),
  requestId?: string(name='RequestId'),
  success?: boolean(name='Success'),
}

model QueryUserDocumentResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: QueryUserDocumentResponseBody(name='body'),
}

async function queryUserDocumentWithOptions(request: QueryUserDocumentRequest, runtime: Util.RuntimeOptions): QueryUserDocumentResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.agentKey)) {
    query['AgentKey'] = request.agentKey;
  }
  if (!Util.isUnset(request.dataId)) {
    query['DataId'] = request.dataId;
  }
  if (!Util.isUnset(request.userId)) {
    query['UserId'] = request.userId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'QueryUserDocument',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function queryUserDocument(request: QueryUserDocumentRequest): QueryUserDocumentResponse {
  var runtime = new Util.RuntimeOptions{};
  return queryUserDocumentWithOptions(request, runtime);
}

model SubmitDocumentImportJobRequest {
  agentKey?: string(name='AgentKey'),
  docs?: [ 
    {
      name?: string(name='Name'),
      ownerId?: string(name='OwnerId'),
      storeId?: string(name='StoreId'),
      tagIds?: [ string ](name='TagIds'),
      type?: string(name='Type'),
      URL?: string(name='URL'),
    }
  ](name='Docs'),
}

model SubmitDocumentImportJobResponseBody = {
  jobId?: string(name='JobId'),
  requestId?: string(name='RequestId'),
}

model SubmitDocumentImportJobResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: SubmitDocumentImportJobResponseBody(name='body'),
}

async function submitDocumentImportJobWithOptions(request: SubmitDocumentImportJobRequest, runtime: Util.RuntimeOptions): SubmitDocumentImportJobResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.agentKey)) {
    query['AgentKey'] = request.agentKey;
  }
  if (!Util.isUnset(request.docs)) {
    query['Docs'] = request.docs;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'SubmitDocumentImportJob',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function submitDocumentImportJob(request: SubmitDocumentImportJobRequest): SubmitDocumentImportJobResponse {
  var runtime = new Util.RuntimeOptions{};
  return submitDocumentImportJobWithOptions(request, runtime);
}

model SubmitText2ImageJobRequest {
  agentKey?: string(name='AgentKey'),
  appId?: string(name='AppId'),
  n?: int32(name='N'),
  negativePrompt?: string(name='NegativePrompt'),
  prompt?: string(name='Prompt'),
  seed?: int32(name='Seed'),
  size?: string(name='Size'),
  style?: string(name='Style'),
}

model SubmitText2ImageJobResponseBody = {
  requestId?: string(name='RequestId'),
  taskId?: string(name='TaskId'),
  taskStatus?: string(name='TaskStatus'),
}

model SubmitText2ImageJobResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: SubmitText2ImageJobResponseBody(name='body'),
}

async function submitText2ImageJobWithOptions(request: SubmitText2ImageJobRequest, runtime: Util.RuntimeOptions): SubmitText2ImageJobResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.agentKey)) {
    query['AgentKey'] = request.agentKey;
  }
  if (!Util.isUnset(request.appId)) {
    query['AppId'] = request.appId;
  }
  if (!Util.isUnset(request.n)) {
    query['N'] = request.n;
  }
  if (!Util.isUnset(request.negativePrompt)) {
    query['NegativePrompt'] = request.negativePrompt;
  }
  if (!Util.isUnset(request.prompt)) {
    query['Prompt'] = request.prompt;
  }
  if (!Util.isUnset(request.seed)) {
    query['Seed'] = request.seed;
  }
  if (!Util.isUnset(request.size)) {
    query['Size'] = request.size;
  }
  if (!Util.isUnset(request.style)) {
    query['Style'] = request.style;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'SubmitText2ImageJob',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function submitText2ImageJob(request: SubmitText2ImageJobRequest): SubmitText2ImageJobResponse {
  var runtime = new Util.RuntimeOptions{};
  return submitText2ImageJobWithOptions(request, runtime);
}

model UpdateDocAttributeRequest {
  agentKey?: string(name='AgentKey'),
  delAllTags?: boolean(name='DelAllTags'),
  docId?: string(name='DocId'),
  name?: string(name='Name'),
  tagIds?: [ string ](name='TagIds'),
}

model UpdateDocAttributeShrinkRequest {
  agentKey?: string(name='AgentKey'),
  delAllTags?: boolean(name='DelAllTags'),
  docId?: string(name='DocId'),
  name?: string(name='Name'),
  tagIdsShrink?: string(name='TagIds'),
}

model UpdateDocAttributeResponseBody = {
  docId?: string(name='DocId'),
  requestId?: string(name='RequestId'),
}

model UpdateDocAttributeResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: UpdateDocAttributeResponseBody(name='body'),
}

async function updateDocAttributeWithOptions(tmpReq: UpdateDocAttributeRequest, runtime: Util.RuntimeOptions): UpdateDocAttributeResponse {
  Util.validateModel(tmpReq);
  var request = new UpdateDocAttributeShrinkRequest{};
  OpenApiUtil.convert(tmpReq, request);
  if (!Util.isUnset(tmpReq.tagIds)) {
    request.tagIdsShrink = OpenApiUtil.arrayToStringWithSpecifiedStyle(tmpReq.tagIds, 'TagIds', 'json');
  }
  var query = {};
  if (!Util.isUnset(request.agentKey)) {
    query['AgentKey'] = request.agentKey;
  }
  if (!Util.isUnset(request.delAllTags)) {
    query['DelAllTags'] = request.delAllTags;
  }
  if (!Util.isUnset(request.docId)) {
    query['DocId'] = request.docId;
  }
  if (!Util.isUnset(request.name)) {
    query['Name'] = request.name;
  }
  if (!Util.isUnset(request.tagIdsShrink)) {
    query['TagIds'] = request.tagIdsShrink;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'UpdateDocAttribute',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function updateDocAttribute(request: UpdateDocAttributeRequest): UpdateDocAttributeResponse {
  var runtime = new Util.RuntimeOptions{};
  return updateDocAttributeWithOptions(request, runtime);
}

model UpdateDocumentTagRequest {
  agentKey?: string(name='AgentKey'),
  name?: string(name='Name'),
  tagId?: string(name='TagId'),
}

model UpdateDocumentTagResponseBody = {
  requestId?: string(name='RequestId'),
  tagId?: string(name='TagId'),
}

model UpdateDocumentTagResponse = {
  headers: map[string]string(name='headers'),
  statusCode: int32(name='statusCode'),
  body: UpdateDocumentTagResponseBody(name='body'),
}

async function updateDocumentTagWithOptions(request: UpdateDocumentTagRequest, runtime: Util.RuntimeOptions): UpdateDocumentTagResponse {
  Util.validateModel(request);
  var query = {};
  if (!Util.isUnset(request.agentKey)) {
    query['AgentKey'] = request.agentKey;
  }
  if (!Util.isUnset(request.name)) {
    query['Name'] = request.name;
  }
  if (!Util.isUnset(request.tagId)) {
    query['TagId'] = request.tagId;
  }
  var req = new OpenApi.OpenApiRequest{ 
    query = OpenApiUtil.query(query),
  };
  var params = new OpenApi.Params{
    action = 'UpdateDocumentTag',
    version = '2023-06-01',
    protocol = 'HTTPS',
    pathname = '/',
    method = 'POST',
    authType = 'AK',
    style = 'RPC',
    reqBodyType = 'formData',
    bodyType = 'json',
  };
  return callApi(params, req, runtime);
}

async function updateDocumentTag(request: UpdateDocumentTagRequest): UpdateDocumentTagResponse {
  var runtime = new Util.RuntimeOptions{};
  return updateDocumentTagWithOptions(request, runtime);
}

